package main

import (
	"fmt"
	"log"
	"net"
	"time"
)

func processClient(conn net.Conn) {
	conn.Write([]byte("hello world"))
	for {
		bytes := make([]byte, 1024)
		n, err := conn.Read(bytes)
		if err != nil {
			conn.Close()
			break
		}
		str := string(bytes[:n])
		fmt.Println("接受来自服务端的消息:", str)
	}
}

func main() {

	for i := 0; i < 100; i++ {
		conn, err := net.Dial("tcp", "127.0.0.1:8888")
		if err != nil {
			log.Println(err)
			return
		}
		go processClient(conn)
	}

	time.Sleep(60 * time.Second)
}
